<!--
INPUT
    <msg_master ORM> $model : The header message
    <int>   $i : topic index
-->

<div class="message_header" onclick="toggleVisibility(document.getElementById('msg_content<?php echo $i ?>'))">
    <div class="left_header">
        <?php
            $datetime = explode(" ", $model->date_stamp);
        ?>
        <div class="date"><?php echo $datetime[0] ?></div>
        <div class="time"><?php echo $datetime[1] ?></div>
    </div>
    <div class="right_header">
        <div class="title_message">
            <?php echo $model->header ?>
        </div>
        <div class="from">
            <span class="msg_atribut">from </span>
            <?php
                $from = new ORM('user');
                $from->find($model->from);
            ?>
            <span class="sender"><a href="<?php echo URL::site("profile?uid=$from->id") ?>"><?php echo $from->username ?></a></span>
        </div>
        <div class="to">
            <span class="msg_atribut">to </span>
            <?php
                $tos = explode(" ", $model->to);
                $temp = array();
                foreach ($tos as $username) {
                    $from->where("`username` = '$username'")->find();
                    $temp[$from->id] = $username;
                }
                $tos = $temp;
            ?>
            <span class="recipient">
                <?php foreach ($tos as $id => $uname) { ?>
                <a href="<?php echo URL::site("profile?uid=$id") ?>">
                    <?php echo $uname ?>
                </a>
                <?php } ?>
            </span>
        </div>
    </div>
    <div class="clear"></div>
</div>
